#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int T,n,m,l,v;
int dece[N];
int num1=0,num2=0;
struct car{
	int d;
	int v;
	int a;
	int f=0;
}c[N];
bool abov[N][N];
int main(){
	memset(abov,0,sizeof(abov));
	cin>>T;
	for(int k=1;k<=T;k++){
		cin>>n>>m>>l>>v;
		for(int i=1;i<=n;i++){
			cin>>c[i].d>>c[i].v>>c[i].a;
		}
		for(int i=1;i<=m;i++){
			cin>>dece[i];
		}
		for(int i=1;i<=n;i++){
			for(int j=1;i<=m;i++){
				if(c[i].d<=dece[j]){
					if(c[i].v*c[i].v+2*c[i].a*(dece[j]-c[i].d)>v*v){
						if(!c[i].f){
							c[i].f=1;
							num1++;
						}
						abov[i][j]=1;
					}
				}
			}
		}
		for(int j=1;j<=m;j++){
			int jud=1;
			for(int i=1;i<=n;i++){
				if (abov[i][j]==1)
					jud=0;
			}
			if(jud)
				num2++;
		}
		cout<<num1<<" "<<num2;
	}
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	return 0;
}
